package com.ecb.business.controller;

import com.ecb.business.dto.api.ApiResult;
import com.ecb.business.dto.contract.manage.ContractDTO;
import com.ecb.business.dto.contract.manage.SearchContractDTO;
import com.ecb.business.service.ContractManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("contractManage")
@Api(tags = "合约管理")
public class ContractManageController {

    @Autowired
    ContractManageService contractManageService;

    @GetMapping("getAllContractByChainId")
    @ApiOperation(value = "根据区块链ID获取合约",notes = "")
    public ApiResult getAllContractByChainId(@RequestBody SearchContractDTO searchContractDTO){
        return ApiResult.T(contractManageService.getAllContractByChainId(searchContractDTO));
    }

    @PostMapping("addContract")
    @ApiOperation(value = "新增合约",notes = "")
    public ApiResult addContract(@RequestBody ContractDTO contractDTO ){
        return ApiResult.T(contractManageService.addContract(contractDTO));
    }

    @PostMapping("updateContract")
    @ApiOperation(value = "更新合约",notes = "")
    public ApiResult updateContract(@RequestBody ContractDTO contractDTO){
        return ApiResult.T(contractManageService.updateContract(contractDTO));
    }
    @PostMapping("deleteContract")
    @ApiOperation(value = "删除合约",notes = "")
    public ApiResult deleteContract(@RequestBody ContractDTO contractDTO){
        return ApiResult.T(contractManageService.deleteContract(contractDTO));
    }
}
